//获取openid 和手机号
export const getPhoneApi = async () => {
	const r = await wx.login()
	// const key = uni.getStorageSync('ylProject').miniKey
	const key = 'yst'
	const {
		data: res
	} = await uni.$http.get('/api/auth/getLoginInfo', {
		code: r.code,
		key
	})
	return res
}

//用户token
export const getTokenApi = async (openId, phone, spreadCode) => {
	// const key = uni.getStorageSync('ylProject').miniKey
	const key = 'hjktjxcx'
	const {
		data: res
	} = await uni.$http.post(`/api/auth/wxLogin`, {
		miniKey: key,
		openId,
		phone,
		register: true,
		spreadCode,
		type: "1"
	})
	return res
}

//根据id获取用户信息
export const getUserApi = async () => {
	const {
		data: res
		} = await uni.$http.post(`/api/auth/getUserInfo`)
	// } = await uni.$http.post(`/api/miniApp/querySingleDetail/${id}`)
	console.log('获取到',JSON.stringify(res))
	return res
}

//获取用户协议 
export const getAgreementApi = async (key) => {
	const {
		data: res
	} = await uni.$http.get(`/api/miniApp/getAgreement/${key}`)
	return res
}

// 注册接口/api/auth/miniApp/register
export const register = async (data) => {
	const {
		data: res
	} = await uni.$http.post(`api/auth/miniApp/register`, {
		miniappKey: 'yst',
		password: data.password,
		phone: data.phone,
		registerType: data.registerType, // 注册方式0手机验证码1账号密码
		userType: data.userType, // 身份0老板1医生2会员
		username: data.username || '',
		verificationCode: data.verificationCode,
	})
	return res
}
// /api/auth/sendSms 发送短信验证码api/auth/sendSms?mobile=18829064002
export const sendSms = async (mobile) => {
	const {
		data: res
	} = await uni.$http.post(`/api/auth/sendSms?mobile=${mobile}`)
	return res
}

// 获取uuid 
export const createCaptcha = async () => {
	const {
		data: res
	} = await uni.$http.get(`/api/captcha/createCaptcha`)
	return res
}

// 验证码登录/api/auth/finalLogin

